package com.foreknow.demo2;

public class Sub extends Base {
    int x = 2;

    @Override
    public void func() {
        System.out.println("sub......");
    }

    public static void main(String[] args) {
        Sub s = new Sub();
        System.out.println(s.x); //2
        s.func(); //sub

        System.out.println("-------------------------------");

        //父类的引用指向子类的对象
        Base base = new Sub();
        System.out.println(base.x); //1
        base.func(); //sub

    }
}
